function converged = has_converged_relatively(old_val, new_val, tolerance)
%Checks if value has converged, by comparing the relative change of the new value w.r.t. the old value.
% If the relative change (i.e. relative to the old value) is smaller than tolerance, the function returns
% 1, otherwise it returns 0. 
    converged = (norm(new_val - old_val) / norm(old_val)) < tolerance;
end